package com.taobao.job;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: caoling
 * Date: 11-3-11
 * Time: 1:42
 * To change this template use File | Settings | File Templates.
 */
public class TextInt implements WritableComparable<TextInt> {

    private String text;
    private int value;

    public TextInt() {
    }

    public TextInt(String text, int value) {
        this.text = text;
        this.value = value;
    }

    public String getFirst() {
        return this.text;
    }

    public int getSecond() {
        return this.value;
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        text = in.readUTF();
        value = in.readInt();
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeUTF(text);
        out.writeInt(value);
    }

    @Override
    public int compareTo(TextInt that) {
        return this.text.compareTo(that.text);
    }
}
